<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/26 0026
 * Time: 下午 5:18
 */
namespace app\common\model;

use think\Model;

class Querydeliverfee extends BaseModel {
    const status_1 = 1; //订单状态(待接单＝1
    const status_2 = 2; // 待取货＝2
    const status_3 = 3; // 配送中＝3
    const status_4 = 4; // 已完成＝4
    const status_5 = 5; // 已取消＝5
    const status_7 = 7; // 已过期=7
    const status_8 = 8; // 指派单=8
    const status_9 = 9; // 妥投异常之物品返回中=9
    const status_10 = 10; // 妥投异常之物品返回完成=10
    const status_1000 = 1000; // 创建达达运单失败=1000

    /**
     * @param $data
     * @return int|string
     * 存储哒哒运费查询数据
     * 预配送订单
     */
    public function insterQueryDeliverFee($data){
        $queryDeliverFee = new Querydeliverfee();
        $findQueryDeliver = $queryDeliverFee->findQueryDeliver($data['order_id']);
        if($findQueryDeliver && !empty($findQueryDeliver)){
            unset($data['id']);
           return self::where("order_id","=",$data['order_id'])->update($data);
        }

        return self::insert($data);
    }

    public function findQueryDeliver($orderId){
        return self::where('order_id','=',$orderId)->find();
    }

    public function updateQueryDeliver($data){
        return $this->where('order_id','=',$data['order_id'])->update($data);
    }

    /**
     *
     */
    public function findDeliverAfter($deliveryNo){
        return self::where('deliveryNo','=',$deliveryNo)->find();
    }

}